package com.onitaku.dibuxodrawer;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class WebFragment extends Fragment {
	  
	  WebView miWebView;
	  final String webDefecto = "http://dibuxo.com";
	  public static String myUrl;

	  @Override
	  public View onCreateView(LayoutInflater inflater, ViewGroup container,
	    Bundle savedInstanceState) {
	   View view = inflater.inflate(R.layout.web_fragment, container, false);
	   miWebView = (WebView)view.findViewById(R.id.miwebview);
	   
	   miWebView.getSettings().setJavaScriptEnabled(true);                
	   miWebView.setWebViewClient(new miWebViewClient());
	   
	   if(myUrl == null){
	    myUrl = webDefecto;
	   }
	   miWebView.loadUrl(myUrl);
	         return view;
	  }
	  
	  private class miWebViewClient extends WebViewClient {
	         @Override
	         public boolean shouldOverrideUrlLoading(WebView view, String url) {
	          myUrl = url;
	             view.loadUrl(url);
	             return true;
	         }
	     }
}